#include "gracesc.h"
#include <unistd.h>

//tests a simple open of xmgrace
void OpenGraceTest(){
     gracesc::Xmgrace graph("param.par", 1);
}

//tests a graph with one horizontal line at y=y
void GraceOneLineTest(float y){
     gracesc::Xmgrace graph("param.par", 1);
     for(int i=0; i<300&&GraceIsOpen(); i++){
          if(i%10 == 0){	
             graph[0].Plot(0,i,y);
	     graph.redraw();
	     sleep(1);
	  }
     }
}

//tests a graph with two lines
void GraceMultiLineTest(){
     gracesc::Xmgrace graph("param.par", 1);
     for(int i=0; i<300&&GraceIsOpen(); i++){
	     if(i%10==0){
             	graph[0].Plot(0,i,.5);
             	graph[0].Plot(1,i,.75);
		graph.redraw();
		sleep(1);
	     }
     }
}

//tests scrolling of a graph, scrolls when plotting past percent % of xmax
void GraceScrollTest(float percent){
     float min=0;
     float max=300;
     float scroll=10;
     gracesc::Xmgrace graph("param.par", 1);
     for(int i=0; i<500&&GraceIsOpen(); i++){
	     if(i%10==0){
             	graph[0].Plot(0,i,.5);
             	if(i/max > percent){
                       max+=scroll;
                       min+=scroll;
                       GracePrintf("World xmin %f",min);
                       GracePrintf("World xmax %f",max);
             	}
		graph.redraw();
		sleep(1);
	     }
     }
}
